import com.bwie.SearchApplication;

import com.bwie.pojo.Goods;
import com.bwie.repository.GoodsRepository;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @program: day0423-pxx
 * @ClassName GoodSearch
 * @description:
 * @author: 段阳
 * @create: 2024-05-08 21:15
 **/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SearchApplication.class)
public class GoodSearchInfo {
//
//    @Autowired
//    private GoodsRepository goodsRepository;
//
//    @Test
//    public void addGoods(){
//        List<Goods> list = new ArrayList<>();
//
////        list.add(new GoodSearch(1,"华为手机",4699.00,"https://dy-060722.oss-cn-beijing.aliyuncs.com/images/2024/05/07/3c151dd1-ece1-46e0-a5da-a0d3fedfa1bejpg","手机",new Date(),120));
////        list.add(new Goods(2,"联想电脑",14699.00,"https://dy-060722.oss-cn-beijing.aliyuncs.com/images/2024/05/07/3c151dd1-ece1-46e0-a5da-a0d3fedfa1bejpg","电脑",new Date(),20));
////        list.add(new Goods(3,"小米手机",3699.00,"https://dy-060722.oss-cn-beijing.aliyuncs.com/images/2024/05/07/3c151dd1-ece1-46e0-a5da-a0d3fedfa1bejpg","手机",new Date(),45));
////        list.add(new Goods(4,"苹果手机",8699.00,"https://dy-060722.oss-cn-beijing.aliyuncs.com/images/2024/05/07/3c151dd1-ece1-46e0-a5da-a0d3fedfa1bejpg","手机",new Date(),67));
////        list.add(new Goods(5,"联想电视",2699.00,"https://dy-060722.oss-cn-beijing.aliyuncs.com/images/2024/05/07/3c151dd1-ece1-46e0-a5da-a0d3fedfa1bejpg","电视",new Date(),89));
////        list.add(new Goods(6,"华为 mate 60",7699.00,"https://dy-060722.oss-cn-beijing.aliyuncs.com/images/2024/05/07/3c151dd1-ece1-46e0-a5da-a0d3fedfa1bejpg","手机",new Date(),6));
////        list.add(new Goods(7,"小米11",4599.00,"https://dy-060722.oss-cn-beijing.aliyuncs.com/images/2024/05/07/3c151dd1-ece1-46e0-a5da-a0d3fedfa1bejpg","手机",new Date(),109));
////        list.add(new Goods(8,"apple",9599.00,"https://dy-060722.oss-cn-beijing.aliyuncs.com/images/2024/05/07/3c151dd1-ece1-46e0-a5da-a0d3fedfa1bejpg","手机",new Date(),19));
////        list.add(new Goods(9,"apple_nice",4899.00,"https://dy-060722.oss-cn-beijing.aliyuncs.com/images/2024/05/07/3c151dd1-ece1-46e0-a5da-a0d3fedfa1bejpg","手机",new Date(),9));
//
////        goodsRepository.saveAll(list);
//    }
//
//    @Test
//    public void findGoodSearchByTitle(){
//        List<Goods> list = goodsRepository.findGoodSearchByTitle("apple");
//        list.forEach(goodSearch ->
//                System.out.println(goodSearch)
//        );
//    }
//
//    @Test
//    public void findGoodSearchByPriceBetween(){
//        List<Goods> list = goodsRepository.findByPriceBetween(5000,10000);
//        list.forEach(goodSearch ->
//                System.out.println(goodSearch)
//        );
//    }
//
//    @Test
//    public void findGoodSearchByStock(){
//        List<Goods> list = goodsRepository.findByStockAfter(10);
//        list.forEach(goodSearch ->
//                System.out.println(goodSearch)
//        );
//    }
//
//    @Test
//    public void findGoodSearchByTitleAndPrice(){
//        List<Goods> list = goodsRepository.findByTitleAndPriceBetween("apple",5000,10000);
//        list.forEach(goodSearch ->
//                System.out.println(goodSearch)
//        );
//    }
//
//
//    @Test
//    public void findGoodSearchByPriceAndStock(){
//        List<Goods> list = goodsRepository.findByPriceBetweenOrStockAfter(5000,10000,100);
//        list.forEach(goodSearch ->
//                System.out.println(goodSearch)
//        );
//    }
//
//    @Test
//    public void findGoodSearchByTitleAndStock(){
//        List<Goods> list = goodsRepository.findByTitleAndStockBeforeOrderByPriceDesc("apple",100);
//        list.forEach(goodSearch ->
//                System.out.println(goodSearch)
//        );
//    }
//
//    @Test
//    public void findGoodSearchByPriceAndStockAndOrderBy(){
//        List<Goods> list = goodsRepository.findByPriceBetweenOrderByStockAsc(5000,10000);
//        list.forEach(goodSearch ->
//                System.out.println(goodSearch)
//        );
//    }
//
//    @Test
//    public void findGoodSearchByTitleAndOrderByCreatedAtDesc(){
//        List<Goods> list = goodsRepository.findByTitleOrderByCreatedAtDesc("apple");
//        list.forEach(goodSearch ->
//                System.out.println(goodSearch)
//        );
//    }
}